<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Dashboard extends CI_Controller {
    
    function __construct() {
        parent::__construct();
        $this->load->model('dashboard_model');
        $this->load->model('novel_model');
        $this->load->model('category_model');
    }

    public function index() {
        $datas = $this->dashboard_model->getChapter_lastest();
        $cached = array();
        foreach($datas as &$data) {
            $arr = array();
            $novelId = $data['novelId'];
            $chapter = $data['chapter'];
            if(!in_array('n_' . $novelId, $cached)) {
                $novel = $this->novel_model->getNovelInfo_by_id($novelId);
                $cached['n_' . $novelId] = $novel;
            } else
                $novel = $cached['n_' . $novelId];
            $data['name'] = $novel->name;
        }
        
        $cats = $this->category_model->getCategory_all();
        $this->load->view('dashboard', array('chapter_log' => $datas, 'cats' => $cats));
    }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */